#pragma once

struct IAMQPPublisher
{
    virtual void Release() = 0;
    virtual void SetServer(const char *lpszIP, unsigned short uPort) = 0;
    virtual void SetAuthentication(const char *lpszUserName, const char *lpszPassword) = 0;
    virtual void SetExchange(const char *lpszExchange) = 0;
	virtual void SetDurable(int nAble) = 0;	//设置持久化
    virtual void SetContentType(const char *lpszContentType) = 0;
    virtual void SetContentEncoding(const char *lpszEncoding) = 0;
    virtual bool Initialize() = 0;
    virtual void Publish(const char *lpszContent, int nLen, const char *lpszRouteKey) = 0;
};


//
// 定义订阅者消息回调函数
// lpszMsg      消息内容的起始地址
// nLen         消息的长度
// lpszRouteKey 消息的路由串
// pContext     调用层私有数据
//
typedef void(*AMQPSubscribeFunc)(const char *lpszMsg, int nLen, const char *lpszRouteKey, void *pContext);

struct IAMQPSubscribe
{
    virtual void Release() = 0;
    virtual void SetServer(const char *lpszIP, unsigned short uPort) = 0;
    virtual void SetAuthentication(const char *lpszUserName, const char *lpszPassword) = 0;
    virtual void SetExchange(const char *lpszExchange) = 0;
    virtual void SetQueue(const char *lpszQueue) = 0;
    virtual void AddBind(const char *lpszBindKey) = 0;
    virtual void SetMessageCallback(AMQPSubscribeFunc fn) = 0;
    virtual void SetContext(void *pContext) = 0;
    virtual bool Initialize() = 0;
};

#ifdef __cplusplus
extern "C" {
#endif

    // 创建 AMQP 对象
    IAMQPPublisher* CreateAMQPPublisher();
    IAMQPSubscribe* CreateAMQPSubscribe();

#ifdef __cplusplus
}
#endif
